package com.example.stock.util;

import com.example.stock.vo.DataVo;
import com.example.stock.vo.common.TradeVo;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author: zhuchunfeng
 * @Description
 * @Date: 2021/1/2 15:16
 * Copyright (c) 2019 北京新媒传信科技有限公司
 */
public class ValidUtil {

    public static void validTime(List<DataVo> data) {
        LocalDateTime min = LocalDateTime.MIN;
        for (DataVo dataVo : data) {
            if (dataVo.getTime().isBefore(min)) {
                throw new RuntimeException("时间乱序");
            }
            min = dataVo.getTime();
        }
    }

    public static void validTimeTrade(List<TradeVo> tradeVos) {
        LocalDateTime min = LocalDateTime.MIN;
        for (TradeVo dataVo : tradeVos) {
            if (dataVo.getTime().isBefore(min)) {
                throw new RuntimeException("时间乱序");
            }
            min = dataVo.getTime();
        }
    }
}
